var datas=[];
function alltypepageing(url,sear) {
    var adata = {
        value : sear,
        pagesize : 999,
        pagenumber : 1
    };
    $.ajax({
        type : "GET",
        data : adata,
        dataType : "json",
        url : url,
        success : function(json) {
            datas = json.records;
            var man=[0,0,0,0,0,0,0];
            var woman=[0,0,0,0,0,0,0];
            var countMan=0,countWoman=0;
            var haveHeartdisease=[0,0,0,0];
            var noHeartdisease=[0,0,0,0];
            var smoke=[0,0,0,0,0];
            for (var i=0;i<datas.length;i++){
                if (datas[i].sex=="男"){
                    if (datas[i].age<20){
                        man[0]+=1;
                    } else if (datas[i]<30){
                        man[1]+=1;
                    } else if (datas[i]<40){
                        man[2]+=1;
                    } else if (datas[i]<50){
                        man[3]+=1;
                    } else if (datas[i]<60){
                        man[4]+=1;
                    } else {
                        man[5]+=1;
                    }
                    countMan+=1;
                } else if (datas[i].sex=="女") {
                    if (datas[i].age<20){
                        woman[0]+=1;
                    } else if (datas[i]<30){
                        woman[1]+=1;
                    } else if (datas[i]<40){
                        woman[2]+=1;
                    } else if (datas[i]<50){
                        woman[3]+=1;
                    } else if (datas[i]<60){
                        woman[4]+=1;
                    } else {
                        woman[5]+=1;
                    }
                    countWoman+=1;
                }
                if (datas[i].heartRadio=="1"){
                    if (datas[i].bmi<"18"){
                        haveHeartdisease[0]+=1;
                    }else if (datas[i].bmi<"23") {
                        haveHeartdisease[1]+=1;
                    }else if (datas[i].bmi<"27") {
                        haveHeartdisease[2]+=1;
                    } else {
                        haveHeartdisease[3]+=1;
                    }
                }else {
                    if (datas[i].bmi<"18"){
                        noHeartdisease[0]+=1;
                    }else if (datas[i].bmi<"23") {
                        noHeartdisease[1]+=1;
                    }else if (datas[i].bmi<"27") {
                        noHeartdisease[2]+=1;
                    } else {
                        noHeartdisease[3]+=1;
                    }
                }

                if (datas[i].smoke<"15"){
                    smoke[0]+=1;
                } else if (datas[i].smoke<"35") {
                    smoke[1]+=1;
                }else if (datas[i].smoke<"60") {
                    smoke[2]+=1;
                }else if (datas[i].smoke<"80") {
                    smoke[3]+=1;
                }else {
                    smoke[4]+=1;
                }
            }


            var dom = document.getElementById("container");
            var myChart = echarts.init(dom);
            option = {
                title : {
                    text: '男女年龄统计',
                },
                tooltip : {
                    trigger: 'axis'
                },
                legend: {
                    data:['男','女']
                },
                toolbox: {
                    show : true,
                    feature : {
                        dataView : {show: true, readOnly: false},
                        magicType : {show: true, type: ['line', 'bar']},
                        restore : {show: true},
                        saveAsImage : {show: true}
                    }
                },
                calculable : true,
                xAxis : [
                    {
                        type : 'category',
                        data : ['<=20','20-30','30-40','40-50','50-60','60-70','>=70']
                    }
                ],
                yAxis : [
                    {
                        type : 'value'
                    }
                ],
                series : [
                    {
                        name:'女',
                        type:'bar',
                        data:woman
                    },
                    {
                        name:'男',
                        type:'bar',
                        data:man
                    }
                ]
            };
            myChart.setOption(option);

            var dom2 = document.getElementById("container2");
            var myChart2 = echarts.init(dom2);
            var option2 = {
                title : {
                    text: '心脏病与BMI统计',
                },
                tooltip : {
                    trigger: 'axis'
                },
                legend: {
                    data:['有心脏病','无心脏病']
                },
                toolbox: {
                    show : true,
                    feature : {
                        dataView : {show: true, readOnly: false},
                        magicType : {show: true, type: ['line', 'bar']},
                        restore : {show: true},
                        saveAsImage : {show: true}
                    }
                },
                calculable : true,
                xAxis : [
                    {
                        type : 'category',
                        data : ['<=18','18-23','23-27','>=27']
                    }
                ],
                yAxis : [
                    {
                        type : 'value'
                    }
                ],
                series : [
                    {
                        name:'有心脏病',
                        type:'line',
                        data:haveHeartdisease
                    },
                    {
                        name:'无心脏病',
                        type:'line',
                        data:noHeartdisease
                    }
                ]
            };
            myChart2.setOption(option2);

            var dom3 = document.getElementById("container3");
            var myChart3 = echarts.init(dom3);
            var option3 = {
                title:{
                    text:'男女比率统计'
                },
                series:[{
                    type:'pie',
                    radius:'60%',
                    data:[
                        {value:countMan,name:'男性'},
                        {value:countWoman,name:'女性'}
                    ]
                }]
            };
            myChart3.setOption(option3);


            var dom4 = document.getElementById("container4");
            var myChart4 = echarts.init(dom4);
            var option4 = {
                title:{
                    text:'抽烟情况统计'
                },
                series:[{
                    type:'pie',
                    radius:'60%',
                    data:[
                        {value:smoke[0],name:'不抽烟'},
                        {value:smoke[1],name:'程度较轻'},
                        {value:smoke[2],name:'程度一般'},
                        {value:smoke[3],name:'程度较重'},
                        {value:smoke[4],name:'程度严重'}
                    ]
                }]
            };
            myChart4.setOption(option4);
        }
    });
}

alltypepageing("/check/findByPage.shtml",null);
